<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div class="box">
            <h3>自动贩卖机</h3>
            <button @click="fn(5)">可乐5元</button>
            <button @click="fn(10)">咖啡10元</button>
            <button @click="fn(8)">牛奶8元</button>
        </div>
        <p>银行卡余额：{{ money }}元</p>
    </div>

    <!-- 2. 导入vue.js -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                money: 100
            },
            methods: {
                fn(n) {
                    this.money = this.money - n
                }
            }
        })
    </script>
</body>
</html>